package.path = package.path .. ';protobuf_lua/protobuf/?.lua'
package.cpath = package.cpath .. ';protobuf_lua/protobuf/?.so'

require 'person_pb'

local person= person_pb.Person()
person.id = 1000
person.name = "Alice"
person.email = "Alice@example.com"
--[[
local home = person.Extensions[person_pb.Phone.phones]:add()
home.num = "2147483647"
home.type = person_pb.Phone.HOME

local home2 = person.Extensions[person_pb.Phone.phones]:add()
home2.num = "2147483647"
home2.type = person_pb.Phone.MOBILE
]]
local msg = person_pb.Person()
local data

local start = os.clock()
for i=1, 100000 do
    data = person:SerializeToString()
    msg:ParseFromString(data)
end
local stop = os.clock()
local cost_time = stop - start

print('cost_time: ', cost_time, ' s')

print(msg)
